home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Freeware / Griffith 0.9.8 / griffith-0.9.8-win32.exe / {app} / lib / plugins / movie / PluginMovie7arte.py next >
Text File  |  2008-11-17  |  5KB  |  153 lines

  1. # -*- coding: UTF-8 -*-
  2.  
  3. __revision__ = '$Id: PluginMovie7arte.py 1040 2008-11-15 21:13:49Z mikej06 $'
  4.  
  5. # Copyright (c) 2005-2006 Vasco Nunes, Piotr Ozarowski
  6. #
  7. # This program is free software; you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License as published by
  9. # the Free Software Foundation; either version 2 of the License, or
  10. # (at your option) any later version.
  11. #
  12. # This program is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. # GNU Library General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU General Public License
  18. # along with this program; if not, write to the Free Software
  19. # 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
  20.  
  21. # You may use and distribute this software under the terms of the
  22. # GNU General Public License, version 2 or later
  23.  
  24. import gutils
  25. import movie
  26. import string
  27.  
  28. plugin_name = "7arte"
  29. plugin_description = "O cinema em Portugal"
  30. plugin_url = "7arte.net"
  31. plugin_language = _("Portuguese")
  32. plugin_author = "Vasco Nunes"
  33. plugin_author_email = "<vasco.m.nunes@gmail.com>"
  34. plugin_version = "0.6"
  35.  
  36. class Plugin(movie.Movie):
  37.     """A movie plugin object"""
  38.     def __init__(self, id):
  39.         self.encode='iso-8859-1'
  40.         self.movie_id = id
  41.         self.url = "http://7arte.net/cgi-bin/filme.pl?codigo=" + str(self.movie_id)
  42.  
  43.     def get_image(self):
  44.         """Finds the film's poster image"""
  45.         self.image_url = "http://7arte.net/imagens/filmes/" + str(self.movie_id) + ".jpg"
  46.  
  47.     def get_o_title(self):
  48.         """Finds the film's original title"""
  49.         self.o_title = string.capwords(gutils.trim(self.page, "</B></FONT><BR>", "<BR>"))
  50.  
  51.     def get_title(self):
  52.         """Finds the film's local title.
  53.         Probably the original title translation"""
  54.         self.title = string.capwords(gutils.trim(self.page, "<FONT SIZE=+1><B>", "</B>"))
  55.  
  56.     def get_director(self):
  57.         """Finds the film's director"""
  58.         self.director = gutils.trim(self.page, "</B> <FONT SIze=-1>", "</FONT><TABLE><TR>")
  59.         self.director = gutils.strip_tags(self.director)
  60.  
  61.     def get_plot(self):
  62.         """Finds the film's plot"""
  63.         self.plot = gutils.trim(self.page, "<B>Sinopse:</B><BR>", "<Font Size=-2>[ www.7arte.net ]</font></FONT></P>")
  64.  
  65.     def get_year(self):
  66.         """Finds the film's year"""
  67.         self.year = gutils.trim(self.page, "<B>Ano:</B> <FONT SIze=-1>", "</FONT>")
  68.  
  69.     def get_runtime(self):
  70.         """Finds the film's running time"""
  71.         self.runtime = gutils.trim(self.page, "<B>Dura", " minutos")
  72.         self.runtime = gutils.after(self.runtime, "-1>")
  73.  
  74.     def get_genre(self):
  75.         """Finds the film's genre"""
  76.         self.genre = gutils.trim(self.page, "nero:</B> <FONT SIze=-1>", "</FONT><BR>")
  77.  
  78.     def get_cast(self):
  79.         self.cast = gutils.trim(self.page, "<B>Actores:</B>", "</FONT></TD>")
  80.         self.cast = string.replace(self.cast, "<B>╗</B> ", "")
  81.  
  82.     def get_classification(self):
  83.         """Find the film's classification"""
  84.         self.classification = gutils.trim(self.page, "<B>Idade:</B> <FONT SIze=-1>", "</FONT>")
  85.  
  86.     def get_studio(self):
  87.         """Find the studio"""
  88.         self.studio = gutils.trim(self.page, "<B>Distribuidora:</B> <FONT SIze=-1>", "</FONT>")
  89.  
  90.     def get_o_site(self):
  91.         """Find the film's oficial site"""
  92.         self.o_site = gutils.trim(self.page, \
  93.             "<A HREF='", \
  94.             "' TARGET=_blank><IMG SRC='/imagens/bf_siteoficial.gif'")
  95.  
  96.     def get_site(self):
  97.         """Find the film's imdb details page"""
  98.         self.site = gutils.trim(self.page, \
  99.             "/imagens/bf_siteoficial.gif' WIDTH=89 HEIGHT=18 BORDER=0 ALT=''>", \
  100.             "' TARGET=_blank><IMG SRC='/imagens/bf_imdb.gif'")
  101.         self.site = gutils.after(self.site, "<A HREF='")
  102.         self.site = string.replace(self.site, "'", "")
  103.  
  104.     def get_trailer(self):
  105.         """Find the film's trailer page or location"""
  106.         self.trailer = gutils.trim(self.page, \
  107.             "/imagens/bf_imdb.gif' WIDTH=89 HEIGHT=18 BORDER=0 ALT=''>", \
  108.             "' TARGET=_blank><IMG SRC='/imagens/bf_trailer.gif'")
  109.         self.trailer = gutils.after(self.trailer, "<A HREF='")
  110.  
  111.     def get_country(self):
  112.         """Find the film's country"""
  113.         self.country = gutils.trim(self.page, "s de Origem:</B> <FONT SIze=-1>", "</FONT><BR>")
  114.  
  115.     def get_rating(self):
  116.         """Find the film's rating. From 0 to 10.
  117.         Convert if needed when assigning."""
  118.         tmp_rating = gutils.trim(self.page, "ticas por:</B></Center>", "c_critica.pl?id=")
  119.         if tmp_rating:
  120.             self.rating = str(float(string.count(tmp_rating, 'estrela.gif'))*2)
  121.  
  122. class SearchPlugin(movie.SearchMovie):
  123.     """A movie search object"""
  124.     def __init__(self):
  125.         self.original_url_search = "http://7arte.net/cgi-bin/arq_search_orig.pl?proc="
  126.         self.translated_url_search = "http://7arte.net/cgi-bin/arq_search.pl?proc="
  127.         self.encode='iso-8859-1'
  128.  
  129.     def search(self, parent_window):
  130.         """Perform the web search"""
  131.         self.open_search(parent_window)
  132.         self.sub_search()
  133.         return self.page
  134.  
  135.     def sub_search(self):
  136.         """Isolating just a portion (with the data we want) of the results"""
  137.         self.page = gutils.trim(self.page, \
  138.             "Resultados Encontrados</I></B></FONT>", "</DIR></FONT>")
  139.  
  140.     def get_searches(self):
  141.         """Try to find both id and film title for each search result"""
  142.         elements = string.split(self.page, "</A><BR>")
  143.         self.number_results = elements[-1]
  144.  
  145.         if (len(elements[0])):
  146.             for element in elements:
  147.                 self.ids.append(gutils.trim(element, "codigo=", "')"))
  148.                 self.titles.append(gutils.convert_entities \
  149.                     (gutils.trim(element, "')\">", " )")) + " )")
  150.         else:
  151.             self.number_results = 0
  152.  
  153.